package com.zzptc.gyc.gfc;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.graphics.Color;
import android.os.Bundle;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import java.text.Format;
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //实例化控件
        ViewPager viewPager=findViewById(R.id.viewPager);
       //创建集合
        final List<Fragment>fragments=new ArrayList<>();
   fragments.add(new FiestFragment());
   fragments.add(new SeconFragment());
   fragments.add(new ThirdlyFragment());
   //适配器
        FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getSupportFragmentManager()) {
            @Override
            public int getCount() {
                //返回集长度
                return fragments.size();
            }

            @NonNull
            @Override
            public Fragment getItem(int position) {
                //数据源的事例
                return fragments.get(position);
            }
        };
        viewPager.setAdapter(adapter);
    }}
